package com.himore.api.web.service.impl;

import java.util.List;

import com.himore.api.common.utils.CommonUtils;
import com.himore.api.common.utils.DateUtils;
import com.himore.api.web.controller.common.CommonController;
import com.himore.api.web.mapper.TSysUserMapper;
import com.himore.api.web.model.TSysUser;
import com.himore.api.web.service.ITSysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 用户库信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-02-01
 */
@Service
public class TSysUserServiceImpl implements ITSysUserService
{
    @Autowired
    private TSysUserMapper tSysUserMapper;

    /**
     * 查询用户库信息
     * 
     * @param userId 用户库信息ID
     * @return 用户库信息
     */
    @Override
    public TSysUser selectTSysUserById(String userId)
    {
        return tSysUserMapper.selectTSysUserById(userId);
    }

    /**
     * 查询用户库信息列表
     * 
     * @param tSysUser 用户库信息
     * @return 用户库信息
     */
    @Override
    public List<TSysUser> selectTSysUserList(TSysUser tSysUser)
    {
        return tSysUserMapper.selectTSysUserList(tSysUser);
    }

    /**
     * 新增用户库信息
     * 
     * @param tSysUser 用户库信息
     * @return 结果
     */
    @Override
    public int insertTSysUser(TSysUser tSysUser)
    {
        tSysUser.setCreateTime(DateUtils.getNowDate());
        tSysUser.setUserId(CommonUtils.getStringRandom(32));
        return tSysUserMapper.insertTSysUser(tSysUser);
    }

    /**
     * 修改用户库信息
     * 
     * @param tSysUser 用户库信息
     * @return 结果
     */
    @Override
    public int updateTSysUser(TSysUser tSysUser)
    {
        tSysUser.setUpdateTime(DateUtils.getNowDate());
        return tSysUserMapper.updateTSysUser(tSysUser);
    }

    /**
     * 批量删除用户库信息
     * 
     * @param userIds 需要删除的用户库信息ID
     * @return 结果
     */
    @Override
    public int deleteTSysUserByIds(String[] userIds)
    {
        return tSysUserMapper.deleteTSysUserByIds(userIds);
    }

    /**
     * 删除用户库信息信息
     * 
     * @param userId 用户库信息ID
     * @return 结果
     */
    @Override
    public int deleteTSysUserById(String userId)
    {
        return tSysUserMapper.deleteTSysUserById(userId);
    }

    @Override
    public boolean selectTSysUserByPhone(String phoneNum) {
        Integer  count =  tSysUserMapper.selectTSysUserByPhone(phoneNum);
        if(count>0){
            return true;
        }else {
            return false;
        }
    }
}
